﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="tablecloth/tablecloth.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="tablecloth/tablecloth.js"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>


<?php

	include("inc/joomlaInt.php");
	include("inc/inc_spiel_bearbeiten.php");
	include("inc/inc_configuration.php");

if ($jUser==0)
{
	echo "Bitte zuerst einloggen!";
}
else
{
	$matchId=$_POST["matchId"];
	
	$notFound = "Nichts vorhanden.";
	

	$hG=$_POST["hG"];
	$gG=$_POST["gG"];
	$hOG=$_POST["hOG"];
	$gOG=$_POST["gOG"];
	$hY=$_POST["hY"];
	$gY=$_POST["gY"];
	$hYR=$_POST["hYR"];
	$gYR=$_POST["gYR"];
	$hR=$_POST["hR"];
	$gR=$_POST["gR"];
	
	$tHi=$_POST["tHi"];
	$tGi=$_POST["tGi"];
	$tHn=$_POST["tHn"];
	$tGn=$_POST["tGn"];
	$uHn=$_POST["uHn"];
	$uGn=$_POST["uGn"];
	
	
	
	
	
	
	
	
	$hTq = createQuery($matchId,1,$tHi,$hTqC);
	$gTq = createQuery($matchId,1,$tGi,$gTqC);
	
	$hOGq = createQuery($matchId,6,$tHi,$hOGqC);
	$gOGq = createQuery($matchId,6,$tGi,$gOGqC);
	
	$hYq = createQuery($matchId,2,$tHi,$hYqC);
	$gYq = createQuery($matchId,2,$tGi,$gYqC);
	
	$hYRq = createQuery($matchId,3,$tHi,$hYRqC);
	$gYRq = createQuery($matchId,3,$tGi,$gYRqC);
	
	$hRq = createQuery($matchId,4,$tHi,$hRqC);
	$gRq = createQuery($matchId,4,$tGi,$gRqC);
	
	$hCG=$hG+$gOG;
	$gCG=$gG+$hOG;
	
	echo "	<center><form action='spiel_bearbeiten_v_2.php' method='post'><table>
			<tr><th colspan='5'></th></tr>
			<tr>
				<td width='24%'><center>$tHn<br><img src='img/logos/",$tHi,".png' width='50' height='50' alt=''></center></td>
				<td width='24%'>$hCG</td>
				<td width='4%'><center>:</center></td>
				<td width='24%'>$gCG</td>
				<td width='24%'><center>$tGn<br><img src='img/logos/",$tGi,".png' width='50' height='50' alt=''></center></td>
			</tr>
			<tr><th colspan='5'></th></tr>
			</table>		
			";
			
			echo "<br><br><h1>Tore</h1><table>";
			
			//Heimtore
			echo "<table><tr><th colspan='2'></th></tr>";
			echo "<tr><td width='50%'>";
			
			if ($hG==0)
			{
				echo "Es wurden keine Heimtore erzielt.";
			}
			
			for($count = 1; $count < $hG+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}

				
				if ($hTqC<=$hG)
				{
					$hTqO = mysql_fetch_object($hTq);
					$pId=$hTqO->playerId;
					$m = $hTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				echo "<select name='homeG",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tHi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='homeGm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
				
				echo "<input type='checkbox' name='homeP",$count,"' value='1'>Elfmeter";
						
			}
			echo "</td>";
				
			//Gasttore
			echo"<td width='50%'>";
			
			if ($gG==0)
				{
					echo "Es wurden keine Gasttore erzielt.";
				}
				
			for($count = 1; $count < $gG+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				

				if ($gTqC<=$hG)
				{
					$gTqO = mysql_fetch_object($gTq);
					$pId=$gTqO->playerId;
					$m = $gTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				
				echo "<select name='guestG",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tGi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='guestGm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
				
				echo "<input type='checkbox' name='guestP",$count,"' value='1'>Elfmeter";
						
			}
			echo "</td></tr><tr><th colspan='2'></th></tr></table>";
			
			
			
			//EIGENTORE
			echo "<br><br><h1>Eigentore</h1><table>";
			
			//Heimtore
			echo "<table><tr><th colspan='2'></th></tr>";
			echo "<tr><td width='50%'>";
			
			if ($hOG==0)
			{
				echo "Es wurden keine Heimtore erzielt.";
			}
			
			for($count = 1; $count < $hOG+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				echo "<select name='homeOG",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tHi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='homeOGm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
				
			}
			echo "</td>";
				
			//Gasttore
			echo"<td width='50%'>";
			
			if ($gOG==0)
				{
					echo "Es wurden keine Gasttore erzielt.";
				}
				
			for($count = 1; $count < $gOG+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				
				echo "<select name='guestOG",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tGi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='guestOGm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
						
			}
			echo "</td></tr><tr><th colspan='2'></th></tr></table>";
			
			
			
			
			//Heim gelbe Karten
			
			echo "<h1>Gelbe Karten</h1>";
				
			echo "<table><tr><th colspan='2'></th></tr><tr><td width='50%'>";	
			
			if ($hY==0)
				{
					echo "Die Heimmannschaft erhielt keine Verwarnung.";
				}
			
				
			for($count = 1; $count < $hY+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				if ($hYqC<=$hY)
				{
					$hTqO = mysql_fetch_object($hYq);
					$pId=$hTqO->playerId;
					$m = $hTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				
				
				echo "<select name='homeY",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tHi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='homeYm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
						
			}	
			
			echo "</td><td width='50%'>";
			
			//Gast gelbe Karten	
			
			
			if ($gY==0)
				{
					echo "Die Gastmannschaft erhielt keine Verwarnung.";
				}
				
			for($count = 1; $count < $gY+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				if ($gYqC<=$gY)
				{
					$hTqO = mysql_fetch_object($gYq);
					$pId=$hTqO->playerId;
					$m = $hTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				echo "<select name='guestY",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tGi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='guestYm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
						
			}
			
			
			echo "</td></tr><tr><th colspan='2'></th></tr></table>";
			
			
			echo "<h1>Gelb - Rote Karten</h1>";
				
			echo "<table><tr><th colspan='2'></th></tr><tr><td width='50%'>";	
			
			if ($hYR==0)
				{
					echo "Die Heimmannschaft erhielt keine gelb-rote Karte.";
				}
			//Heim gelb-rote Karten	
			for($count = 1; $count < $hYR+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				if ($hYRqC<=$hYR)
				{
					$hTqO = mysql_fetch_object($hYRq);
					$pId=$hTqO->playerId;
					$m = $hTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				echo "<select name='homeYR",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tHi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='homeYRm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
						
			}	
			
			echo "</td><td width='50%'>";
			
			//Gast gelb-rote Karten	
			
			if ($gYR==0)
				{
					echo "Die Gastmannschaft erhielt keine gelb-rote Karte.";
				}
				
			for($count = 1; $count < $gYR+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				if ($gYRqC<=$gYR)
				{
					$hTqO = mysql_fetch_object($gYRq);
					$pId=$hTqO->playerId;
					$m = $hTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				echo "<select name='guestYR",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tGi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='guestYRm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
						
			}
			
			
			echo "</td></tr><tr><th colspan='2'></th></tr></table>";
			
			
			echo "<h1>Rote Karten</h1>";
				
			echo "<table><tr><th colspan='2'></th></tr><tr><td width='50%'>";	
			
			//Heim rote Karten	
			
			if ($hR==0)
				{
					echo "Die Heimmannschaft erhielt keinen Platzverweis.";
				}
				
			for($count = 1; $count < $hR+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				if ($hRqC<=$RG)
				{
					$hTqO = mysql_fetch_object($hRq);
					$pId=$hTqO->playerId;
					$m = $hTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				echo "<select name='homeR",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tHi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='homeRm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
						
			}	
			
			echo "</td><td width='50%'>";
			
			//Gast rote Karten	
			
			if ($gR==0)
				{
					echo "Die Gastmannschaft erhielt keinen Platzverweis.";
				}
				
			for($count = 1; $count < $gR+1; $count++)
			{
				if ($count>1)
				{
					echo"<br><br>";
				}
				
				if ($gRqC<=$gR)
				{
					$hTqO = mysql_fetch_object($gRq);
					$pId=$hTqO->playerId;
					$m = $hTqO->minute;
					$tSp="";
					$tSm="";
				}
				
				echo "<select name='guestR",$count,"' Size='1'>";
					$yHa="SELECT * FROM $tbl_players WHERE teamId=$tGi ORDER by name ASC";
					$yHq = mysql_query($yHa);
					while ($row = mysql_fetch_object($yHq))
						{
							$t=$row->id;
							$vn=$row->firstname;
							$nn=$row->name;
							$k="";
							if ($vn!="")
							{
								$k=", ";
							}
							
							echo "<Option Value='",$t,"'>",$nn,"$k",$vn,"</option>";
						}
				echo "</select>";
				echo "<select name='guestRm",$count,"' Size='1'>";
					$minute = 1;
						while($minute < 121)
						{
							if ($minute==$m)
							{
								$tSm=" selected";
							}
							
							echo '<Option',$tSm,' Value="',$minute,'">',$minute,'</option>';
							$tSm="";
							$minute++;
						}
				echo "</select>";
						
			}
			
			
			echo "</td></tr><tr><th colspan='2'></th></tr></table>";
			
			
			
				
	

	
	
	
	
	
	
	echo "<br><br><input type='submit' value='Bestätigen' class='button eintragen'>";
	
	echo "<input type='hidden' name='tHi' value='$tHi'>";
	echo "<input type='hidden' name='tGi' value='$tGi'>";
	
	echo "<input type='hidden' name='tHn' value='$tHn'>";
	echo "<input type='hidden' name='tGn' value='$tGn'>";
	echo "<input type='hidden' name='uHn' value='$uHn'>";
	echo "<input type='hidden' name='uGn' value='$uGn'>";
	echo "<input type='hidden' name='matchId' value='$matchId'>";
	echo "<input type='hidden' name='hG' value='$hG'>";
	echo "<input type='hidden' name='gG' value='$gG'>";
	echo "<input type='hidden' name='hOG' value='$hOG'>";
	echo "<input type='hidden' name='gOG' value='$gOG'>";
	echo "<input type='hidden' name='hY' value='$hY'>";
	echo "<input type='hidden' name='gY' value='$gY'>";
	echo "<input type='hidden' name='hYR' value='$hYR'>";
	echo "<input type='hidden' name='gYR' value='$gYR'>";
	echo "<input type='hidden' name='hR' value='$hR'>";
	echo "<input type='hidden' name='gR' value='$gR'>";
	
	echo "</form>";
	
	
	
	
	echo '<br><br><a href="lima.php" class="button zurueck">Zurück</a></center>';
	
}	
	
?>

</body>
</html>